///************************************************************************
/// <copyrigth>2018-2019 Corporation.All Rights Reserved</copyrigth>
/// <author>tangyingzhong</author>
/// <contact>tangyz114987@outlook.com</contact>
/// <version>v1.0.0</version>
/// <describe>
/// Framework interfaces
///</describe>
/// <date>2020/7/26</date>
///***********************************************************************
#ifndef IFRAMEWORK_H
#define IFRAMEWORK_H

#include "Base/IPlugin.h"

#define FRAMEWORK_NAME "Framework"

#define FRAMEWORK_VERSION 1,0,0

#define FRAMEWORK_PLUGIN_BASE FRAMEWORK_NAME,FRAMEWORK_VERSION

#define FRAMEWORK_IS_START_ON_LOAD true

#define FRAMEWORK_IS_MAIN_SERVICE true

#define FRAMEWORK_PLUGIN FRAMEWORK_PLUGIN_BASE,FRAMEWORK_IS_START_ON_LOAD,FRAMEWORK_IS_MAIN_SERVICE

struct Task
{
	typedef std::function<void()> CallBackFunc;

	// Task id (32 bits GUID)
	std::string strTaskId;

	// Task name
	std::string strTaskName;

	// Task excute interval time (ms)
	int iExcuteIntervalTimeMs;

	// Task callback function
	std::shared_ptr<CallBackFunc> pUserFunc;

	// Is one time task
	bool bIsOneTimeTask;

	Task()
	{
		strTaskId = "";

		strTaskName = "";

		iExcuteIntervalTimeMs = 1000;

		bIsOneTimeTask = true;
	}
};

class IFramework:public IPlugin
{
public:
	// Detructe the IFramework
	virtual ~IFramework() {	};

public:
	// Is core's debug mode
	virtual bool IsDebugMode() = 0;

	// Get the plugin by name and version
	virtual IPlugin* GetPlugin(std::string strPluginName,
		int iMajorVersion,
		int iMinorVersion,
		int iModifyVersion) = 0;

	// Add Task to the micro core
	virtual bool AddTask(Task& UserTask) = 0;

	// Pause the task
	virtual void PauseTask(std::string strTaskId) = 0;

	// Resume the task
	virtual void ResumeTask(std::string strTaskId) = 0;

	// Stop the task
	virtual void StopTask(std::string strTaskId) = 0;
};

#endif // IFRAMEWORK_H
